#! /bin/bash

# 获取环境变量
PLAY_HOME=/opt/playground

# 将环境变量持久化到/etc/profile中
profile=/etc/profile
sudo sed -i "/^export PLAY_HOME/d" $profile
echo "export PLAY_HOME=$PLAY_HOME" | sudo tee -a $profile >/dev/null

# 更新/etc/profile文件
source /etc/profile && echo "更新/etc/profile文件成功"

# host配置文件修改
echo "将集群ip及其映射的hostname添加到/etc/hosts中"
$PLAY_HOME/systems/addClusterIps.sh

# 关闭防火墙、SELINUX ，需要输入参数close或start
echo "关闭防火墙、SELINUX"
$PLAY_HOME/systems/closeFirewall.sh close

# 添加bigdata用户名 ，需要输入参数create或delete
# echo "添加bigdata用户名"
# /home/hadoop/automaticDeploy/systems/autoCreateUser.sh create

# 配置yum源
# echo "配置yum源"
# /home/hadoop/automaticDeploy/systems/configureYum.sh $hostname

# 配置SSH无密码登录
#echo "集群各节点之间配置SSH无密码登录"
#$PLAY_HOME/systems/sshFreeLogin.sh "do"

# 检查免密登录是否生效
$PLAY_HOME/systems/sshFreeLogin.sh "check"

# 配置JDK环境
#if [ "$jdk_bool" = "1" ]; then
#    echo "配置 JDK 环境..."
#    $PLAY_HOME/systems/configureJDK.sh
#else
#    echo "跳过 JDK 安装"
#    # 在这里可以继续执行其他操作
#fi

#9.配置SCALA环境
# echo "9.配置scala环境"
# /home/hadoop/automaticDeploy/systems/configureScala.sh
echo "--------------------"
echo "|   $(hostname)环境check成功！|"
echo "--------------------"